<template>
  <div class="car-in-out">
    <p class="title">
      车辆入场实时动态
      <img style="height: 0.7em;margin-left: 0.3em;" src="../../../../assets/bigDataSourceImage/barTitleIcon.png">
    </p>
    <div class="scroll-box">
      <div id="scroll1">
        <p class="in-car" v-for="(item,index) in carNums" :class="{activeInCar:index%2}">
          <span class="car-num">{{item.carNum}}</span>
          <span class="in-date">{{item.carDate}}</span>
          <span class="in-parking">{{item.carParkin}}</span>
        </p>
      </div>
      <div id="scroll2">
        <p class="in-car" v-for="(item,index) in carNums" :class="{activeInCar:index%2}">
          <span class="car-num">{{item.carNum}}</span>
          <span class="in-date">{{item.carDate}}</span>
          <span class="in-parking">{{item.carParkin}}</span>
        </p>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'car-in-out',
    data() {
      return {
        carNums: [
          {
            carNum: '冀AY5897',
            carDate: '2020-12-16 10:30:00',
            carParkin: '石家庄科技中心'
          },
          {
            carNum: '冀AY5897',
            carDate: '2020-12-16 10:30:00',
            carParkin: '石家庄科技中心'
          },
          {
            carNum: '冀AY5897',
            carDate: '2020-12-16 10:30:00',
            carParkin: '石家庄科技中心'
          },
          {
            carNum: '冀AY5897',
            carDate: '2020-12-16 10:30:00',
            carParkin: '石家庄科技中心'
          },
          {
            carNum: '冀AY5897',
            carDate: '2020-12-16 10:30:00',
            carParkin: '石家庄科技中心'
          },
          {
            carNum: '冀AY5897',
            carDate: '2020-12-16 10:30:00',
            carParkin: '石家庄科技中心'
          },
          {
            carNum: '冀AY5897',
            carDate: '2020-12-16 10:30:00',
            carParkin: '石家庄科技中心'
          },
          {
            carNum: '冀AY5897',
            carDate: '2020-12-16 10:30:00',
            carParkin: '石家庄科技中心'
          },
          {
            carNum: '冀AY5897',
            carDate: '2020-12-16 10:30:00',
            carParkin: '石家庄科技中心'
          },
          {
            carNum: '冀AY5897',
            carDate: '2020-12-16 10:30:00',
            carParkin: '石家庄科技中心'
          },
          {
            carNum: '冀AY5897',
            carDate: '2020-12-16 10:30:00',
            carParkin: '石家庄科技中心'
          },
          {
            carNum: '冀AY5897',
            carDate: '2020-12-16 10:30:00',
            carParkin: '石家庄科技中心'
          },
        ]
      }
    },
    mounted() {
      this.scroll();
    },
    beforeDestroy() {
      if (this.timer) {
        clearInterval(this.timer);
      }
    },
    methods: {
      scroll() {
        let len = 0;
        let lenght;
        let height;
        // setTimeout(function() {
        //   height = document.getElementById('scroll1').clientHeight
        // },30000)
        height = document.getElementById('scroll1').clientHeight
        this.timer = setInterval(function() {
          len -= 1;
          lenght = len + "px";
          document.getElementById('scroll1').style.marginTop = lenght;
          if(len == -height) {
            len = 0;
          }
        },60)
      },
    }
  }
</script>

<style scoped>
  p {
    margin: 0;
  }
  .car-in-out {
    height: 100%;
    border: 1px solid transparent;
    border-image-source: url('../../../../assets/bigDataSourceImage/box1.png');
    border-image-slice: 26 26 26 26;
    border-image-repeat: stretch;
    border-image-width: 26px;
    box-sizing: border-box;
    padding: 1.4em;
  }
  .title {
    margin: 0;
    color: #fff;
    font-size: 0.8em;
  }
  .scroll-box {
    /* border: 1px solid red; */
    height: calc(100% - 1.6em);
    overflow: hidden;
    margin-top: 0.6em;
  }
  .in-car {
    font-size: 12px;
    font-family: Adobe Heiti Std R;
    background: rgba(0, 170, 218, 0.1);
    padding: 6px 12px;
    overflow: hidden;
    text-overflow:ellipsis;
    white-space: nowrap;
    color: #5E737C ;
    font-family: Adobe Heiti Std R;
  }
  .car-num {
    color: #21B5FF;
    /* font-weight: bold; */

  }
  .in-date {
    padding: 0 4%;
    border-left: 1px solid #5E737C;
    border-right: 1px solid #5E737C;
    margin-left: 4%;
    margin-right: 4%;
  }
  .activeInCar {
    background-color: transparent;
  }

</style>
